/*
* Copyright (c) 2025 -present FengJinjian ( 751965763@qq.com )
*/
import { request } from "@/utils/request/index";
import type {ListResult} from "@/api/model/listModel";
/**
 *  接口
 */
export interface OrderInfo {
            orderNumber?: string;
            userId?: number;
}

export interface ApiResponse<T> {
    code: number;
    message: string;
    data: T;
    }
export type OrderResponse = ApiResponse<number>; // 新创建的合同ID



enum OrderApi {
  Page = '/product-orders/',
  Create = '/product-orders/',
  Update = '/product-orders',
  Delete = '/product-orders',
  Detail = '/product-orders/detail',
}

/**
 * 获取列表
 */
export const getOrderList = (params: OrderInfo ) => {
  return request.get<OrderResponse>({
    url: OrderApi.Page,
    params,
  });
};

/**
 * 创建
 */
export const createOrder = (params: OrderInfo) => {
  return request.post({
    url: OrderApi.Create,
    params,
  });
};

/**
 * 更新
 */
export const updateOrder = (params: OrderInfo) => {
  return request.put({
    url: OrderApi.Update+`/`+params.id,
    params,
  });
};

/**
 * 删除
 */
export const deleteOrder = (id: number) => {
  return request.delete({
    url: OrderApi.Delete+`/`+id
  });
};

/**
 * 获取详情
 */
export const getOrderDetail = (id: number) => {
  return   request.get<OrderInfo>({
    url: OrderApi.Detail,
    params: { id },
  });
};